import requests
from requests.sessions import Session
import sys
from pathlib import Path
from os.path import dirname, abspath
path = dirname(str(Path(__file__).resolve().parents[1]))
if path not in sys.path:
    sys.path.append(path)
from xkw_data_query.config_parse import get_sso_config


headers = {
        "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7",
        "Accept-Encoding": "gzip, deflate, br, zstd",
        "Accept-Language": "zh-CN,zh;q=0.9",
        "Cache-Control": "max-age=0",
        "Connection": "keep-alive",
        "Content-Length": "6673",
        "Content-Type": "application/x-www-form-urlencoded",
        "Cookie": "xkw-device-id=39EFB1E6C56645A8419B7DA15933AEC3; UT1=ut-713951-TwJC0dbkLFSXyw; UT2=ut-713951-TwJC0dbkLFSXyw; softCartList=; lookedsoftstorage=[{%22softid%22:%2246861982%22}%2C{%22softid%22:%2244730013%22}]; _ga=GA1.1.2034690098.1740628052; _ga_BXF15YRN21=GS1.1.1740637796.2.0.1740637796.0.0.0; xk.identity=%7b%7d; Hm_lvt_0e522924b4bbb2ce3f663e505b2f1f9c=1742282235,1744334874; user-visitor-log=%7B%22firstTime%22%3A%222025-04-11T01%3A28%3A01.776Z%22%2C%22times%22%3A5%2C%22lastTime%22%3A%222025-04-11T01%3A28%3A04.750Z%22%7D; xkw-fs-id=41264d3a68c06a8a3e8313f660291d9d; Hm_lvt_384e6cb5ddbf481e97ba12544207c0ee=1746521861; HMACCOUNT=B3588D69855EBA21; ssoid=504c37d4-635c-47d6-8866-66e2d31e65c0; Hm_lpvt_384e6cb5ddbf481e97ba12544207c0ee=1746866053",
        "Host": "",
        "Origin": "",
        "Referer": "",
        "Sec-Fetch-Dest": "document",
        "Sec-Fetch-Mode": "navigate",
        "Sec-Fetch-Site": "same-origin",
        "Sec-Fetch-User": "?1",
        "Upgrade-Insecure-Requests": "1",
        "User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/135.0.0.0 Safari/537.36",
        "sec-ch-ua": '"Google Chrome";v="135", "Not-A.Brand";v="8", "Chromium";v="135"',
        "sec-ch-ua-mobile": "?0",
        "sec-ch-ua-platform": '"macOS"',
    }

def dev_login_cookie():
    curl = "https://t.zxxk.com/login?service=http://local-paper-split.xkw.com:8191/callback?client_name=paper.split"
    headers["Host"] = "t.zxxk.com"
    headers["Origin"] = "https://t.zxxk.com"
    headers["Referer"] = curl
    config = get_sso_config(env="dev")
    data = {
        "username": str(config["username"]),
        "password": config["password"],
        "_eventId": "submit",
        "flowId": "5ea2e81604354042b47256e2e1c02ddc",
        "rememberMe": "true",
        "execution": "e33f2e13-b2bb-4226-8864-5bcf885814f0_ZXlKaGJHY2lPaUpJVXpVeE1pSjkuQ2JkRlFOZFc0OE5OQndkcTZiTnBESkxUVHJlYmlXRHRua0hCalZJYXhMbTk5NlBFT2xDdk1VUkk4OVpENUFCMHcyMDJmeXN2MjJyQXBLUXpzYzBya0dPbWxCU1BlbklJVkVLemhJRGx6QlBNa0VGcHZLdjVwS0Q3WjVjN0U0dm4wTFRZOCtHNDRGcFFHRUZZblh0SHcrajNmd01iUTB0Mi9Ra0xDbHY2RVpzWmczRlVZRTdzdk9JZjRNSkRlV3ZLZU80MzZORkJ5ODhlR05sM1dVbkR0YVBSWFJsRGExd3VnMEJFS2dWbjV4Wnh2SUJoYml3bEVxbzVaQlB5RmJTc05DbzRwajVPaFlWMVlId3Y4RlNPdGU4Tm5hNm5vSGRFT052cTl4d00yQ0k4d0UzY28zSkxuY3N0OEFKRlhDVmxWTFQremtEb040UE0xNWlmcUhHQi8zeXhod3MxcGFnT1N6VXA1YnIvVHQrWjFKV2oxdGJZNm5WbTZmbFY3MHF2cW1SZkdBMmN1ZFRPMkdBTGludXNtOW1wckpsQ2QwVUxCZjI4VzBuQmtJeWRRODdSUDNkdDI5ZzhFTVFCSnJlVFBXdzdMZFZFMWtkd0pkbkR0MWlFL200Si9lWmM5UEZBZUVJZWJtam91ZVFVTz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ZNQnZVdk5ySHpjMis3MHpybndnUkhmVFIyV3ZvWjhyb08rUGt2cjU4ejRmZTFIWUI0Zi8va0dlcDdVaGhkR0srVkVDRWRLRW41bmZnQXk5UGUwVXlDd3VpU3hoTHBFcHlETm82bndtK3YrNDkxZzBUcVgwOXVxdkxDd0x4cmh4VDJSUjhXMk1ZREFpQXlid09JM2JUVTdQRzdtZjg0Zz09LkhZbkZMMlRBd0N4Q2VQLTdUNHRvX0FmbkJGcTRETFVEcDVqZ3VzTlYxZUNCNDc4YXNicHdzS0hWRnRCVmFteFBuUk1YMmJJQUxxN0xNNkFhelJTVl9R",
    }
    return login_and_get_cookie(curl, data, headers)


def prod_login_cookie():
    curl = "https://sso.zxxk.com/login?service=http://woodpecker-dev.xkw.com/console/callback?client_name=woodpecker"
    headers["Host"] = "sso.zxxk.com"
    headers["Origin"] = "https://sso.zxxk.com"
    headers["Referer"] = curl
    config = get_sso_config()
    data = {
        "username": str(config["username"]),
        "password": config["password"],
        "_eventId": "submit",
        "flowId": "9955c63d828445359d46e1ba44b8a358",
        "rememberMe": "true",
        "execution": "881f9256-c51c-40e8-85a8-c254c15c8a29_ZXlKaGJHY2lPaUpJVXpVeE1pSjkubzhEcGw0cjR1NzVzdktLS0RXc2ZJQ1doM0FpRG9MQlJyS0F6Q2QxSzlic1RnY3N2MDgvbmNscnVVaDFXaGdlRXpYOS85blVDOHNmazlFZzN0dHZLMXFwR3dlUFM3L3IySlVqcHpKNDIxaWZTOWVJSHBjWkUwVXU3YTZHQVBzZExsNzhhNlNIemxydktJR3M1R1FCNHNrV3JjT1JxTHBlMEliZUNaRHpHSnhMazhZa2NWazFCTUxnTlg2dXdVSWx2ZTlnMXVuM0JPL2dkNllZYjFGWUd0T3VUZUZ1eDk2SU5tT05LcGw4OGgyMWNBSVFrUnlVdDcrRkhaMStVd20xbndzR1NxUDMzWUs3dUMzUkNCVis2Z3NaeXJSRk9pUUpNUS92Z3J3YkEzbkdIUnA2c0cvZS94ckQ0VGxRR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cDJiVEJhS3dLYUxPM0tuS3M3RUUxYUZRMWNORm9mYjUvamxvOVkwOG1tUEpzTnZ4Z1hRRmhOU01OaFZDSHhINjU3U0ExWGZJSThCdExnanVWOVpkWlpmL2YvVnRnaCtGREU5SzNqSDRuWU5MT3p2d0F0NDJiRW5QQkN0T1lZamF4U0xZWXIxYzRGd3cwOVhPRkxFRzFDYnJjeFJLdFdZUEpOVFVYSHR6UDRmZ3U3WmUzN2xyZ1lYMk5HbkhydDZyS0hVSFNlOHlMNEtGeVdjdU5ZOXZYdDF0eTBLVEFGZTJROE1ncGFwSVFQS3V2MnVBdGRPcnhodU90Q095UFByN3JnWGJLUVpJVzJqQ1pCN1VkeGdYWmowNkVqTUpqQXVhYVJJMGdINmgvWTE5RUlBQnJmeGJFcTZoaWJ5NHBRQWwxVERNUmNWbU8yak4yS2VGMEovcWxBeTRYMkNyait0aWk1d2lUNFlaVysrTVZKRzJrcUN5ak5BR0RTMy84MkkyejlHTWpEWHI2VzJFTUh3ZVVFSTBNSnljZ1ozSExvOElIcDZkMi9YSTArZURxeG5uTG8wbUVrVmJqcHdQemZ0YUxRTko2WUcva1dleHVCSTdSWTFrV2U1M2xKN09OZStQbzNBPT0uYi1ocHMxNHJEcU1ua0U4aVV3UXpMbFd3ZDRhMXZuS2lwOVBob3F3Ti1RT0VwZERvc2FhTnZoM1VwLWczRThwekdPMzB0VDdCcDVTcldLcmlmQTdzamc=",
    }
    return login_and_get_cookie(curl, data, headers)


def login_and_get_cookie(url, data, headers):
    session = Session()
    response = session.post(url, data=data, headers=headers, allow_redirects=False)
    url_service_route = response.headers["Location"]

    res_service_route = session.get(url_service_route, allow_redirects=False)
    cookies = session.cookies.get_dict()

    url_callback = res_service_route.headers["Location"]
    res_callback = session.get(url_callback, allow_redirects=False)
    # cookie已经获取到了，或许前两步就获取到了
    cookies = session.cookies.get_dict()
    jsession_id = cookies.get("JSESSIONID")
    session_id = cookies.get("SESSION")

    # 需要的cookie JSESSIONID、SESSION
    api_cookies = f"JSESSIONID={jsession_id};SESSION={session_id}"
    return api_cookies


if __name__ == "__main__":
    # api_cookies = dev_login_cookie()
    # ress = requests.get(
    #     "http://local-paper-split.xkw.com:8191/paper_paragraph/4051/htmlFromParagraph",
    #     headers={"cookie": api_cookies},
    # )
    # print(ress.text)

    api_cookies = prod_login_cookie()
    ress = requests.get(
        "https://woodpecker-dev.xkw.com/console/paper_paragraph/4051/htmlFromParagraph",
        headers={"cookie": api_cookies},
    )
    print(ress.text)
